#!/bin/bash
#mysql自动化安装脚本
echo "----- mysql自动化卸载脚本开始执行 -----"
#!/bin/bash

while true
do
    read -r -p "你确认执行删除数据库操作？删除数据库是不可逆操作，请确定删除前已完成数据库备份！ [Y/n] " input
    case $input in
        [yY][eE][sS]|[yY])
            echo "Yes"
            systemctl stop mysqld
            mysql_pack=$(rpm -qa|grep mysql)
            for i in  $mysql_pack
            do
                rpm -e ${i} --nodeps
            done
            rm -rf /var/lib/mysql
            rm -rf /usr/bin/mysql
            rm -rf /usr/lib64/mysql
            rm -rf /usr/share/mysql
            rm -rf /usr/include/mysql
            rm -rf  /var/log/mysqld.log
            if [ $? -eq 0 ]
            then
               echo "卸载成功"
            else
               echo $?
               exit
            fi
            echo "----- mysql自动化卸载脚本执行完毕 -----"
            exit
            ;;
        [nN][oO]|[nN])
            echo "No"
            exit
            ;;
        *)
            echo "输入错误，请重新输入！"
            ;;
    esac
done
